<? 
// instantiate meeting manager
require('../includes/class.main.php');
$manager = new MeetingManager();

// include admin header
include('../template/admin-header.php');

// process form data
if (isset($_SESSION['updateStatus']) && $_SESSION['updateStatus'] != '') {
	$status = $_SESSION['updateStatus'];
	$_SESSION['updateStatus'] = '';	
}
	
?>
<div class="left">
<?php 
include('menu.php');
?>
</div>

<div class="right">
	<h1>
		<span class="blue">Upload New Store Data</span>
	</h1>
	<br> <b>Select File To Upload</b><br>
	<form enctype="multipart/form-data" action="upload-store.php"
		method="POST">
		<input type="hidden" name="MAX_FILE_SIZE" value="750000" /> 
			<input name="xlsdata" type="file" /> <input
			type="submit" name="submit" formaction="upload-store.php" value="Upload" />
	</form>
	<?
	if (isset($status)) {
		echo "<br><hr><pre>$status</pre><hr>\n";
	} else {
		echo "<br><br>";
		
		if (file_exists('../xlsdata/store_data.xls')) {
			echo "<img src=\"../images/checkmark_green.png\" width=20 height=18>";
			echo "The last upload was ". date("M d, Y h:i:s T",filectime('../xlsdata/store_data.xls')) .".<br><br>\n";
		} else {
			echo "<img src=\"../images/x_red.png\" width=20 height=18>";
			echo "No store data file is on the server.<br><br>\n";
		}
		
		$db = new DB();
		$result = $db->setQuery("select count(*) from store");
		$count = $result->fetch_row();
		
		
		if ($count[0] > 0) {
			$result = $db->setQuery("select max(updated) from store");
			$updated = $result->fetch_row();
			echo "<img src=\"../images/checkmark_green.png\" width=20 height=18>";
			echo "There are $count[0] store records in the store database.";
			echo "The last update was at ". date("M d, Y h:i:s T", strtotime($updated[0])) ."<br><br>\n";
		} else {
			echo "<img src=\"../images/x_red.png\" width=20 height=18>";
			echo "There are no store records in the meeting database.<br><br>\n";
		}
	}
	?>
		
</div>

<?  include('../template/admin-footer.php'); ?>
